package zhr.chapter9;

import javax.swing.*;
import java.awt.*;
//GridLayout网式布局
public class GridLayoutFrame extends JFrame {
    private JButton button1;
    private JButton button2;
    private JButton button3;
    private JButton button4;
    private JButton button5;
    private JPanel panel1;

    private JButton button6;
    private JButton button7;
    private JButton button8;
    public GridLayoutFrame(){
        button1 = new JButton("Button1");
        button2 = new JButton("Button2");
        button3 = new JButton("Button3");
        button4 = new JButton("Button4");
        button5 = new JButton("Button5");
        panel1 = new JPanel();
        button6 = new JButton("Button6");
        button7 = new JButton("Button7");
        button8 = new JButton("Button8");
        this.setLayout(new GridLayout(2,3));
        this.add(button1);
        this.add(button2);
        this.add(button3);
        this.add(button4);
        this.add(button5);
        this.add(panel1);
        panel1.setLayout(new GridLayout(3,1));
        panel1.add(button6);
        panel1.add(button7);
        panel1.add(button8);
        this.setTitle("GridLayout网式布局");
        this.setSize(600,400);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
}
